package com.higgins.eventtracking.server.projectmanagement;

import java.util.Date;
import java.util.List;

import com.higgins.eventtracking.client.SecurityAccessDeniedException;
import com.higgins.eventtracking.client.projectmanagement.HistoryItemDTO;
import com.higgins.eventtracking.client.projectmanagement.ProjectItemDTO;
import com.higgins.eventtracking.client.projectmanagement.ProjectService;
import com.higgins.eventtracking.shared.FieldVerifier;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
public class ProjectServiceImpl extends RemoteServiceServlet implements
		ProjectService {
	private ProjectDataSource dataSource = new ProjectDataSource();
	
	public ProjectServiceImpl()	{
		dataSource.openConnection();
	}
	public void finalize()	{
		dataSource.closeConnection();
		dataSource = null;
	}
	
	@Override
	public List<ProjectItemDTO> retrieveProjectItems(Long parentId)
			throws IllegalArgumentException {
		return dataSource.retrieveProjectItems(parentId);
	}

	@Override
	public List<Long> retrieveParentIds(Long parentId)
			throws IllegalArgumentException {
		return dataSource.retrieveParentIds(parentId);
	}
	
	@Override
	public Long insetProjectItem(ProjectItemDTO item)
			throws IllegalArgumentException {
		return dataSource.insetProjectItem(item);
	}
	@Override
	public Long updateProjectItemTask(Long id, String task, Long parentId)
			throws IllegalArgumentException {
		return dataSource.updateProjectItemTask(id, task, parentId);
	}
	@Override
	public Long updateProjectItemForecast(Long id, Double forecast, Long parentId)
			throws IllegalArgumentException {
		return dataSource.updateProjectItemForecast(id, forecast, parentId);
	}
	@Override
	public List<Long> updateProjectItemPriority(Long idOne, Integer priorityOne, Long idTwo, Integer priorityTwo, Long parentId)
		throws IllegalArgumentException {
		return dataSource.updateProjectItemPriority(idOne, priorityOne, idTwo, priorityTwo, parentId);
	}
	
	@Override
	public Boolean deleteProjectItem(Long id) throws IllegalArgumentException {
		return dataSource.deleteProjectItem(id);
	}
	@Override
	public Boolean startTimer(Long id) throws IllegalArgumentException {
		return dataSource.startTimer(id);
	}
	@Override
	public Boolean stopTimer(Long id) throws IllegalArgumentException {
		return dataSource.stopTimer(id);
	}
	@Override
	public Boolean setPermanent(Long id) throws IllegalArgumentException	{
		return dataSource.setPermanent(id);
	}
	@Override
	public Boolean setNotPermanent(Long id) throws IllegalArgumentException	{
		return dataSource.setNotPermanent(id);
	}
	@Override
	public Long isActive(Long id) throws IllegalArgumentException {
		return dataSource.isActive(id);
	}
	@Override
	public Long updateProjectItemComplete(Long id, Double complete,
			Long parentId) throws IllegalArgumentException {
		return dataSource.updateProjectItemComplete(id, complete, parentId);
	}
	@Override
	public 	List<HistoryItemDTO> retrieveHistory(String date, Boolean showAllEvents, Boolean showDistinctList) throws IllegalArgumentException	{
		return dataSource.retrieveHistory(date, showAllEvents, showDistinctList);
	}
	@Override
	public String retrieveTodaysSimpleFormatDate()	{
		return dataSource.retrieveTodaysSimpleFormatDate();
	}
	@Override
	public Boolean setImmediate(Long id) throws IllegalArgumentException {
		// TODO Auto-generated method stub
		return dataSource.setImmediate(id);
	}
	@Override
	public Boolean setNotImmediate(Long id) throws IllegalArgumentException {
		// TODO Auto-generated method stub
		return dataSource.setNotImmediate(id);
	}
	@Override
	public Boolean setFollowUp(Long id) throws IllegalArgumentException {
		// TODO Auto-generated method stub
		return dataSource.setFollowUp(id);
	}
	@Override
	public Boolean setNotFollowUp(Long id) throws IllegalArgumentException {
		// TODO Auto-generated method stub
		return dataSource.setNotFollowUp(id);
	}
	@Override
	public List<String> retrieveImmediate() throws IllegalArgumentException {
		// TODO Auto-generated method stub
		return dataSource.retrieveImmediate();
	}
	@Override
	public List<String> retrieveFollowUp() throws IllegalArgumentException {
		// TODO Auto-generated method stub
		return dataSource.retrieveFollowUp();
	}
	@Override
	public Long updateFollowUpDate(Long id, String followUpDate)	throws IllegalArgumentException	{
		return dataSource.updateFollowUpDate(id, followUpDate);
	}
	@Override
	public Long updateStartTimestamp(Long id, Date startTimestamp)	throws IllegalArgumentException	{
		return dataSource.updateStartTimestamp(id, startTimestamp);
	}
		
	@Override
	public Long updateEndTimestamp(Long id, Date endTimestamp)	throws IllegalArgumentException		{
		return dataSource.updateEndTimestamp(id, endTimestamp);
	}
	@Override
	public Boolean checkAccess() throws IllegalArgumentException	{
		return dataSource.checkAccess();
	}
	
	
}
